<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:79:"E:\phpstudy_pro\WWW\nmg03\public/../application/admin\view\schools\addform.html";i:1704600709;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $setting['webname']; ?> - 单招学校管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="/public/static/admin/layui/css/layui.css" rel="stylesheet">
    <link href="/public/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/public/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
    <link href="/public/static/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <style>
        #demo2 img{
            height: 110px;
        }
    </style>

</head>

<body class="gray-bg">
    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-sm-4">
            <h2>单招学校管理</h2>
            <ol class="breadcrumb">
                <li>
                    <a href="<?php echo url('Admins/admin'); ?>">主页</a>
                </li>
                <li>
                    <strong>单招学校</strong>
                </li>
            </ol>
        </div>
    </div>
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>添加单招学校</h5>
                    </div>

                    <div class="ibox-content">
                        <form class="form-horizontal" id="form1">
                            <!--标题-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">学校名称：</label>
                                <div class="col-sm-4">
                                    <input type="text" placeholder="学校名称" name="name" value="" id="name" class="form-control">
                                </div>
                                <div class='col-sm-6'></div>
                            </div>
                            <!--学校-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">学校logo：</label>
                                <div class="col-sm-6">
                                    <input type="button" class="btn btn-success" value="已上传的图片" id="selffile">
                                    <button type="button" class="btn btn-info" id="test1">上传图片</button>
                                    <div class="layui-upload-list">
                                        <img class="layui-upload-img" id="demo1" style='max-width:100%'>
                                        <p id="demoText"></p>
                                    </div>
                                </div>
                                <div class='col-sm-4'></div>
                            </div>
                            <!--学校地址-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">学校地址：</label>
                                <div class="col-sm-4">
                                    <input type="text" placeholder="学校地址" value="" name="address" id="address" class="form-control">
                                </div>
                                <div class='col-sm-6'></div>
                            </div>
							<!--学校性质-->
							<div class="form-group">
							    <label class="col-sm-2 control-label">学校性质：</label>
							    <div class="col-sm-4">
							        <input type="text" placeholder="学校性质" list="school_quality" name="quality" value="" id="quality" class="form-control">
							        <datalist id="school_quality">
										<option value="公办"></option>
										<option value="民办"></option>
									</datalist>
								</div>
							    <div class='col-sm-6'></div>
							</div>
							<!--学校等级-->
							<div class="form-group">
								<label class="col-sm-2 control-label">学校评级：</label>
								<div class="col-sm-4">
									<input type="text" placeholder="学校评级" list="school_grade" name="grade" value="" id="grade" class="form-control">
									<datalist id="school_grade">
										<option value="普通高校"></option>
										<option value="国家示范性院校"></option>
										<option value="211工程高校"></option>
										<option value="985工程高校"></option>
										<option value="全国重点大学"></option>
										<option value="双一流大学"></option>
									</datalist>
								</div>
								<div class='col-sm-6'></div>
							</div>
                            <!--学校等级-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">学校等级：</label>
                                <div class="col-sm-4">
                                    <input type="text" placeholder="学校等级" name="class" list="school_class" value="" id="class" class="form-control">
								   <datalist id="school_class">
										<option value="专科"></option>
										<option value="本科"></option>
								   </datalist>
								</div>
                                <div class='col-sm-6'></div>
                            </div>
                            <!--学校属性-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">学校属性：</label>
                                <div class="col-sm-4">
                                    <input type="text" placeholder="学校属性" name="property" list="school_property" value="" id="property" class="form-control">
									<datalist id="school_property">
										<option value="综合类"></option>
										<option value="工科大学"></option>
										<option value="科技类大学"></option>
										<option value="经济类大学"></option>
										<option value="师范类大学"></option>
										<option value="医科类大学"></option>
										<option value="艺术类大学"></option>
										<option value="综合艺术类大学"></option>
										<option value="语言文学类大学"></option>
										<option value="宗教类大学"></option>
									</datalist>
								</div>
                                <div class='col-sm-6'></div>
                            </div>
                            <!--是否二次单招-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否二次单招：</label>
                                <div class="col-sm-4">
                                    <select class="form-control m-b" name="whethertwice" id="whethertwice">
                                        <option value="1">是</option>
                                        <option value="0">否</option>
                                    </select>
                                </div>
                                <div class='col-sm-6'></div>
                            </div>
                            <!--排序-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">排序：</label>
                                <div class="col-sm-4">
                                    <input type="text" placeholder="请输入键名" name="sort" id="sort" value="" class="form-control">
                                </div>
                                <div class='col-sm-6'></div>
                            </div>
                            <!--状态-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">状态：</label>
                                <div class="col-sm-4">
                                    <select class="form-control m-b" name="status" id="status">
                                        <option value="1">显示</option>
                                        <option value="0">不显示</option>
                                    </select>
                                </div>
                                <div class='col-sm-6'></div>
                            </div>
                            <!--学校介绍-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">学校介绍：</label>
                                <div class="col-sm-6">
                                    <div class="ibox-content no-padding" >
                                        <div class="summernote" id="introduce">
                                            
                                        </div>
                                    </div>
                                </div>
                                <div class='col-sm-6'></div>
                            </div>
                        
                            <!--确认-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label"></label>
                                <div class="col-sm-4">
                                    <button type="button" class="btn btn-info btn-sm btn-block" id="save"> 保存修改</button>
                                </div>
                                <div class='col-sm-6'></div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div> 
    </div>
    <link rel="stylesheet" href="/public/static/admin/css/imglist.css">

    <!--弹出已上传的图片-->
    <div class="layer_notive" >
        <ul id="imglist"></ul>
        <div style="clear:both"></div>
    </div>
    <!-- 全局js -->
    <script src="/public/static/admin/layui/layui.js"></script>
    <script src="/public/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/public/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script src="/public/static/admin/js/content.js?v=1.0.0"></script>

    <script src="/public/static/admin/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
    <!-- SUMMERNOTE -->
    <script src="/public/static/admin/js/plugins/summernote/summernote.min.js"></script>
    <script src="/public/static/admin/js/plugins/summernote/summernote-zh-CN.js"></script>
    <script>
		
        layui.use('upload', function() { //独立版的layer无需执行这一句
            var $ = layui.jquery, layer = layui.layer,upload = layui.upload; //独立版的layer无需执行这一句
            var photo = "";
            $("#save").click(function(){
				var data ={}
				$("#form1").serializeArray().forEach(v=>{
				    data[v.name] = v.value
				});
				data["logo"] = photo;
				data["introduce"] = $('#introduce').code()
                //添加请求
                $.post("<?php echo url('Schools/add'); ?>",data,function(data){
                    top.layer.msg(data.msg,{time:2000,shade:0.5},function(){
                        if(data.url){
                            window.location.href = data.url;
                        }
                    });
                });
            });
            //图片上传路径
            $imgpath = "/public/static/admin/uploads/shcoollogo/"
            //普通图片上传
            var uploadInst = upload.render({
                elem: '#test1'
                ,url: "<?php echo url('Schools/upload'); ?>"
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    obj.preview(function(index, file, result){
                        $('#demo1').attr('src', result); //图片链接（base64）
                    });
                }
                ,done: function(res){
                    //如果上传失败
                    if(res.code == 0){
                        return top.layer.msg('上传失败',{shade:0.5});
                    }else if(res.code){
                        //上传成功
                        photo = res.photo;
                        return top.layer.msg('上传成功',{shade:0.5});
                    }
                }
                ,error: function(){
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function(){
                        uploadInst.upload();
                    });
                }
            });

            //显示本地图片
            $("#selffile").click(function () {
                $.post("<?php echo url('Base/getmyfiles'); ?>",{path:$imgpath},function(data){
                    console.log(data);
                    var str = "";
                    for( i in data.msg){
                      str += "<li><img src='"+$imgpath+data.msg[i]+"' class='imglist' data-photo='"+data.msg[i]+"' onclick='changecss(this)' alt=''><div class='del_div'><i class='fa fa-close del' title='删除' data-path='"+$imgpath+data.msg[i]+"'></i></div></li>";
                    }
                    $("#imglist").html(str);
                    //页面层
                    layer.open({
                        type: 1,
                        skin: false, //加上边框
                        title: "已上传的图片",
                        area: ['700px', '600px'], //宽高
                        btn:["确认","取消"],
                        content: $(".layer_notive"),  //调到新增页面
                        yes:function(){
                            var newImgsrc = $(".active").attr("src");
                            $('#demo1').attr('src', newImgsrc); //图片链接（base64）
                            $('#demo1').attr('width','100%');
                            photo = newImgsrc;
                            layer.closeAll();
                        }
                    });
                });
            });
          //删除图片
          $("#imglist").on("click",".del",function(v){
            $this = $(this);
            //页面层
            top.layer.msg('你确定要删除这张图片吗?', {
              time: 20000, //20s后自动关闭
              shade:0.5,
              btn: ['确定', '取消'],
              yes:function(){
                var data  = {
                  "path" : $this.data("path")
                }
                $.post("<?php echo url('Base/delfile'); ?>",data,function(data){
                  top.layer.msg(data.msg,{time:2000,shade:0.5},function(){
                    $.post("<?php echo url('Base/getmyfiles'); ?>",{path:$imgpath},function(data) {
                      console.log(data);
                      var str = "";
                      for (i in data.msg) {
                        str += "<li><img src='"+$imgpath + data.msg[i] + "' class='imglist' data-photo='" + data.msg[i] + "' onclick='changecss(this)' alt=''><div class='del_div'><i class='fa fa-close del' title='删除' data-path='"+$imgpath + data.msg[i] + "'></i></div></li>";
                      }
                      $("#imglist").html(str);
                    });
                  });
                });
              }
            });
          });

        });

        //点击图片选择图片
        function changecss(obj){
            $(".imglist").removeClass("active");
            $(obj).addClass("active");
        }
        //富文本框
        $(document).ready(function () {

            $('.summernote').summernote({
                lang: 'zh-CN'
            });

        });
    </script>

  </body>
</html>
